/// <summary>
/// Copyright 2010 Ivo Limmen (ivo@limmen.org)
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
/// 
/// http://www.apache.org/licenses/LICENSE-2.0
/// 
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.
/// </summary>

using System;
using Services.Logging.Api;
using Services.Configuration.Api;

namespace Services.TaskService.Api
{
	public interface ITask
	{
		string GetName();

		string GetDescription();

		/// <summary>
		/// If this method returns <code>true</code> the scheduler will restart the task even if there was
		/// an error.
		/// </summary>
		/// <returns>
		/// A <see cref="System.Boolean"/>
		/// </returns>
		bool RescheduleAfterError();

		void Initialize();

		/// <summary>
		/// This method will be called by the scheduler when the date/time expires that was returned
		/// by the GetNextExecutionTime method.
		/// </summary>
		void Execute();

		void SetLogger(ILogger logger);

        void SetConfiguration(IResolver resolver);

		/// <summary>
		/// Returns the next DateTime this Task is required to run again.
		/// </summary>
		/// <returns>
		/// A <see cref="System.Nullable"/>
		/// </returns>
		DateTime? GetNextExecutionTime();
	}
}
